package com.zhongkeruan.product.service.impl;

import com.codingapi.tx.annotation.TxTransaction;
import com.zhongkeruan.common.model.Product;
import com.zhongkeruan.common.model.User;
import com.zhongkeruan.product.dao.ProductDao;
import com.zhongkeruan.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author yangyao
 * @Description: UserServiceImpl
 * @date 2019/1/11 15:13
 */
@Service
public class ProductServiceImpl implements ProductService {

    @Autowired
    private ProductDao productDao;

    public List<Product> getProductList() throws Exception {
        List<Product> productList = productDao.getProductList();
        return productList;
    }

    public Product getProductById(Long id) throws Exception {
        Product product = productDao.getProductById(id);
        int a = 1/0;
        return product;
    }

    @Transactional
    @TxTransaction
    public int addProduct(Product product) throws Exception {
        //int a =1/0;
        return productDao.addProduct(product);
    }
}
